What if a student cannot pay the APC of a journal
No, they won't/can't take legal action. The worst that could occur is that they won't accept the paper. Nothing to worry about beyond that. 

But if you are a student, explore with your university whether they have funds to pay the fees. Some will be able to do this and others not. If you are working with a professor perhaps s/he has grant money that will pay such fees also. It is worth asking. 

Not all journals will have liberal forgiveness policies, but some do. Just ask and be prepared to state your case.