You have to build your .data value the hard way, you'll also need to build the data in the loop and set it afterwards:
data = { level21: { }, level22: { } };
for( var i = 0; i <= 5; i++ ){
data.level21[i] = 'hello';
data.level22[i] = 'world';
}
$('#item').data('level1', data);
You have to use the [] form of object access to get i evaluated. You also need to build the data first to avoid overwriting the 'level1' every time through the loop.
Also, if you're only using contiguous integers starting at zero inside data.level21 and data.level22, then simple arrays might be a better choice than objects:
// Note the "{}" -> "[]" change in here
data = { level21: [ ], level22: [ ] };
// The syntax is the same for the rest