You can use quotes inside of echo statements. Simply \ them out. For example, your code from above with quotes would be
echo "<a href=\"#\" onClick=\"history.go(-1)\">";
Another way to do it which I prefer over using "onClick" is
echo "<a href=\"javascript:history.go(-1)\">";
Hope it helps...