Some of the possible reasons:
- In baroque Germany, operas were almost exclusively financed by and produced for the princes' private entertainment.
- Bach's employer(s) might not have had the budget and/or theatre to allow him to write an opera.
- Operas were supposed to be light entertainment. Bach wasn't famous for anything light at all, his music was considered too somber and complex by most of his contemporaries.
- Bach did not like operas too much -- presumably because they all were the light entertainment they were supposed to be.
- He was too busy to write an opera just for fun, after all he had to deliver enormous amounts of music (a cantata every week).