In general you can replace any occurrence of "thee" with "the" but not vice versa. "The" is more commonly used while "thee" is used for emphasis. As you mentioned there are some cases where you can use "thee" without emphasis, but I think it's best to mostly use "the" until you get the hang of where you can use "thee".