I maintain a personal dictionary of words I have learned from Duolingo. Почему and Зачем are next to each other in my dictionary, and they are the only words into which I have invested such notes as below. Please note, my etymology is highly suspect, but it helps me out a lot.
Почему - why (asks about the past, asks about the cause of something; think of “по” as a prefix asking, “by”, since чем comes from что, and so you are asking, “by what means?”)
Зачем - why (asks about the future, and asks about the purpose of something; think of “за” as a prefix asking, “behind”, since чем comes from что, and so you are asking, “what’s behind this?”)
I think the implication of the question, "Почему ты здесь?" is along the lines of, "What brought you here - did someone drop you off in their car?" If it were phrased instead, "Зачем ты здесь?", the implication would be, "What is your purpose for being here? You gonna rob the joint?"
Почему ты опоздал? ‧ Why are you late? ( involuntary, inadvertent, undeliberate; what unforeseen intervention or disruption caused unwelcome lateness? )
Зачем ты опоздал? ‧ Why are you late? ( intentional, calculated, purposeful, deliberate; What is the motivation behind a planned lateness? )
За-че́м ‧ Why [ purpose inquiry - answer: In order to ‧ Чтобы ]
По-че-му́ ‧ Why [ cause inquiry - answer: Because ‧ Почему что ]