Which is better: to work a haraam job but have a home OR to have no job but to be homeless? Can men go to university in order to study?
All perfect praise be to Allah, The Lord of the Worlds. I testify that there is none worthy of worship except Allah, and that Muhammad is His slave and Messenger.
A Muslim should look for a permissible job to earn his sustenance and that of those whom he is obliged to spend on, and to fulfill his considerable needs.
It is not permissible for him to work in a forbidden job unless he cannot find another job while he is in dire need for it, in a way that he will not have money (except what he earns from this job) to spend on himself and his children, and to fulfill his considerable needs, such as accommodation, and so forth. In this case, it would be permissible for him to stay in this job (according to the need only), until he finds another job.
Meanwhile, he should strive to find another job, and must know that a necessity should be valued according to its proper and actual value.
As regards men going to study at the university, then this is permissible in principle.
Allah knows best.
You can search for fatwa through many choices