Yes, the dir attribute (and the ‘direction’ CSS property, which it maps to) are hints to the rendering engine about the intended direction of the language in an element, to help the bi-directional rendering algorithm render things better.
Check out this link: http://software.hixie.ch/utilities/js/live-dom-viewer/?<!DOCTYPE%20html>
Try removing the dir attribute, and notice how the visual ordering of things changes - this is because digits are only “weakly LTR”, so they’ll arrange themselves in an LTR order, but they get grouped with the Hebrew (“strongly RTL” characters) as part of an “RTL run”, so they’ll always be to the left (following, in RTL) the Hebrew. The dir attribute then informs the browser what the “overall” direction is supposed to be, so you either get the “foo” first and then the RTL run to the right (following, in LTR), or you get “foo” on the right side and then the RTL run to its left.
Getting your head wrapped around the bidi algorithm can be pretty confusing, so don’t worry too hard about it. Just understand that the dir attribute’s purpose is for a page written in an RTL language (or an element that’s going to contain RTL content) to tell the browser this - it doesn’t do anything useful for pages written entirely in LTR languages like English.