Why did Snape become a teacher when he hates children so much? Why didn't he, for instance, set up a potions emporium on Diagon Alley?
Snape became a teacher to protect Harry and as penance for Lily's death
Snape felt terribly guilty of his own role in Lily's death. Dumbledore made use of that guilt, and made him promise to protect Harry Potter. Therefore he became a teacher at Hogwarts, because he had to be close to Harry in order to protect him.
“If you loved Lily Evans, if you truly loved her, then your way forward is clear.” Snape seemed to peer through a haze of pain, and Dumbledore’s words appeared to take a long time to reach him.
“You know how and why she died. Make sure it was not in vain. Help me protect Lily’s son.”
There was a long pause, and slowly Snape regained control of himself, mastered his own breathing. At last he said, “Very well. Very well. But never – never tell, Dumbledore! This must be between us! Swear it! I cannot bear…especially Potter’s son…I want your word!”
-Harry Potter and the Deathly Hallows
Since Voldemort was ultimately responsible for Lily's death, Snape joined the Order of the Phoenix, and in order to be active in the cause against the Dark Lord, he needed a credible excuse to be in contact with the headmaster. Teaching proved to be a good cover, since Voldemort never realized Snape's betrayal until his death.
Snape may have have become a teacher on Dumbledore’s orders.
When Snape tells Dumbledore about the prophecy he overheard, and that the Dark Lord believed it to be about Lily Evans, ne promised Dumbledore anything in return for Lily’s safety.
“And what will you give me in return, Severus?’
‘In – in return?’ Snape gaped at Dumbledore, and Harry expected him to protest, but after a long moment he said, ‘Anything.”
- Harry Potter and the Deathly Hallows, Chapter 33 (The Prince’s Tale)
When Umbridge asks him in Harry’s fifth year, Snape says he’d been teaching at Hogwarts for fourteen years. If he’d started at the beginning of the school year, he’d have been teaching since September 1981.
“Now … how long have you been teaching at Hogwarts?’ she asked, her quill poised over her clipboard.
‘Fourteen years,’ Snape replied. His expression was unfathomable. His eyes on Snape, Harry added a few drops to his potion; it hissed menacingly and turned from turquoise to orange.”
- Harry Potter and the Order of the Phoenix, Chapter 17 (Educational Decree Number Twenty-Four)
The prophecy was made shortly before Harry’s birth on July 31st, 1980, so the timing fits - Snape would have started teaching after he’d already joined Dumbledore, and right before Lily’s death. Dumbledore could have told Snape to become a teacher at Hogwarts, and he’d have complied in exchange for Lily’s safety, despite teaching probably not being anything like the career he’d originally intended to have. Snape would be unlikely to refuse since he valued Lily over all, including his own career prospects.
Dumbledore chose his own teaching career as a way to keep out of trouble.
Dumbledore may have suggested it for multiple reasons. He considered teaching a safe option for “reformed” people - he chose to teach because he thought it was the safest place for him.
“I had proven, as a very young man, that power was my weakness and my temptation. It is a curious thing, Harry, but perhaps those who are best suited to power are those who have never sought it. Those who, like you, have leadership thrust upon them, and take up the mantle because they must, and find to their own surprise that they wear it well.
‘I was safer at Hogwarts. I think I was a good teacher –”
- Harry Potter and the Deathly Hallows, Chapter 35 (King’s Cross)
Though he trusted Snape, Dumbledore may have thought having him teach at Hogwarts would be a safe place to have him especially when he’d only just joined, or perhaps he had some other reason.
He became a teacher on Voldemord's orders.
He tells this to Bellatrix in The Half-Blood Prince, Chapter2,
“You ask where I was when the Dark Lord fell. I was where he had ordered me to be, at Hogwarts School of Witchcraft and Wizardry, because he wished me to spy upon Albus Dumbledore. You know, I presume, that it was on the Dark Lord’s orders that I took up the post?”
She nodded almost imperceptibly and then opened her mouth, but Snape forestalled her.
He remained there for reasons we can speculate on, as the other answers have done, but he became a teacher under orders.