What is this this square hole in bathroom rough in used for?
That's for a shower drain. It's common to leave an opening about that size to allow for slight variation in tub position, manipulation of the trap assembly, etc. You should find a stub under the dirt. Normally you'd remove the lumber, which was a temporary concrete form.