Hard to tell if there's anything wrong without knowing what was going through your friend's head when he wrote that.
"ps" gets a list of processes. "grep -c apache" searches that list for the word "apache", and the "-c" option (at least in linux) will make it return just a count of how many matching lines it found. What the number of apache processes has to do with server load is beyond me though, unless it's a very very rough estimate.
As for why it gives you 0, I'm not sure. It could be that "apache" is the wrong thing to grep for. Redhat 8 (the last redhat I used) called it httpd instead of apache, so this command would give you nothing. Or perhaps the number of processes is just too low on that machine. On my dev box I only have 5, which would come up as 0% for $percent1 (or 1% for $percent2).