1
Yesterday it happened an accident outside my school.
Yesterday there was an accident outside my school.
Yesterday an accident happened outside my school.
Do not use it happened + event. The event can be the subject of happen: ‘Something strange happened yesterday.’
To introduce an event, there was is often the more natural choice: ‘There was an accident outside my school.’
2
What happened your phone?
What happened to your phone?
Use happen to + person/thing to ask about something that affected them: ‘What happened to your phone?’